/** @namespace app.model.Type */
module.exports = app => {
  const {STRING, INTEGER, DATE} = app.Sequelize;
  const Type = app.model.define('type', {
    name: {
      type: STRING,
      allowNull: false,
      unique: 'name',
    },
  }, {
    timestamps: false,
    tableName: 'spider_type',
  });

  Type.associate = () => {
    Type.hasMany(app.model.TypeData);
    app.model.TypeData.belongsTo(app.model.Type);
  };

  return Type;
};